<?php

/**

 * 充值卡充值！本源码由网店运维开发！QQ499063702 作者所作 wansyb
 * @since      File available since Release v1.1
 */



//use Shopnc\Tpl;



defined('InShopNC') or exit('Access Invalid!');



class member_fundControl extends mobileMemberControl {



    public function __construct() {

        parent::__construct();

    }


/**
     * 充值列表
     */
    public function indexOp(){
        $condition = array();
        $condition['pdr_member_id'] = $_SESSION['member_id'];
        if (!empty($_GET['pdr_sn'])) {
            $condition['pdr_sn'] = $_GET['pdr_sn'];
        }

        $model_pd = Model('predeposit');
        $log_list = $model_pd->getPdRechargeList($condition,$this->page,'*','pdr_id desc');
        $page_count = $model_pd->gettotalpage();
        output_data(array('log_list' => $log_list), mobile_page($page_count));
    }
	
	 /**
     * 预存款变更日志
     */
    public function predepositlogOp(){
        $model_pd = Model('predeposit');
        $condition = array();
        $condition['lg_member_id'] = $_SESSION['member_id'];
        $list = $model_pd->getPdLogList($condition,$this->page,'*','lg_id desc');

        $page_count = $model_pd->gettotalpage();
        output_data(array('list' => $list), mobile_page($page_count));
    }
	    /**
     * 充值列表
     */
    public function pdrechargelistOp(){
        $condition = array();
        $condition['pdr_member_id'] = $_SESSION['member_id'];
        if (!empty($_GET['pdr_sn'])) {
            $condition['pdr_sn'] = $_GET['pdr_sn'];
        }

        $model_pd = Model('predeposit');
        $list = $model_pd->getPdRechargeList($condition,$this->page,'*','pdr_id desc');

        $page_count = $model_pd->gettotalpage();
        output_data(array('list' => $list), mobile_page($page_count));
    }
	/**
     * 提现列表
     */
    public function pdcashlistOp(){
        $condition = array();
        $condition['pdc_member_id'] =  $_SESSION['member_id'];
        if (preg_match('/^\d+$/',$_GET['sn_search'])) {
            $condition['pdc_sn'] = $_GET['sn_search'];
        }
        if (isset($_GET['paystate_search'])){
            $condition['pdc_payment_state'] = intval($_GET['paystate_search']);
        }
        $model_pd = Model('predeposit');
        $list = $model_pd->getPdCashList($condition,$this->page,'*','pdc_id desc');

        $page_count = $model_pd->gettotalpage();
        output_data(array('list' => $list), mobile_page($page_count));
    }

    /**
     * 平台充值卡
     */
    public function rechargecard_addOp()
    {

        $sn = (string) $_POST['rc_sn'];
        if (!$sn || strlen($sn) > 50) {
            showMessage('平台充值卡卡号不能为空且长度不能大于50', '', 'html', 'error');
            exit;
        }

        try {
            model('predeposit')->addRechargeCard($sn, $_SESSION);
            showMessage('平台充值卡使用成功', urlMember('predeposit', 'rcb_log_list'));
        } catch (Exception $e) {
            showMessage($e->getMessage(), '', 'html', 'error');
            exit;
        }
    }
    /**
     * 充值卡余额变更日志
     */
    public function rcblogOp()
    {
        $model = Model();
        $log_list = $model->table('rcb_log')->where(array(
            'member_id' => $_SESSION['member_id'],
        ))->page()->order('id desc')->select();

        $page_count = $log_list->gettotalpage();
        output_data(array('log_list' => $log_list), mobile_page($page_count));
    }




}

